全部文档

5.2Modbus通道管理

提供了Modbus通道的增删改查、查询指定边缘节点下的所有通道、查询指定设备下的所有通道、创建Modbus设备的网关通道配置、查询Modbus设备的网关通道配置等功能。

5.2.1创建Modbus通道

功能描述:新建一个通道,返回新建通道id。

POST  /api/v1/gateway/channels

Query:

Name Type Description Required
gatewayId int 网关设备ID Yes

Body:

Name Type Description Required
name string 通道名称 Yes
model string 通道模式(0 : RTU/ 1 : TCP),目前只支持RTU模式 Yes
serialPort string 串口号 Yes
baudRate int 波特率(300/600/1200/1440/2400/4800/9600/19200/38400 /43000/56000/57600/115200/230400)默认为1200 Yes
dataBits int 数据位(5/6/7/8)默认为8 Yes
checkBits int 数据位(无校验:0;奇校验:1;偶校验:2)默认为无校验 Yes
stopBits int 停止位(1/2)默认为2 Yes

Body example:

{
  "name": "modbuschannel",
  "model": "0",
  "serialPort": "34134134134",
  "baudRate": 1200,
  "dataBits": 8,
  "checkBits": 0,
  "stopBits": 2
}

cURL example:

curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/gateway/channels?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}&gatewayId=10000801' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
              "name": "modbuschannel",
              "model": "0",
              "serialPort": "34134134134",
              "baudRate": 1200,
              "dataBits": 8,
              "checkBits": 0,
              "stopBits": 2
            }'

Response data:

Name Type Description
id int 当前页码
gatewayId int 网关ID
name string 通道名称
model int 通道模式(0 : RTU/ 1 : TCP)
ip string ip地址
port long 端口
serialPort string 串口号
baudRate long 波特率
dataBits int 数据位
checkBits int 是否校验数据位
stopBits int 停止位
created long 创建时间
modified long 更新时间

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 14,
    "gatewayid": 10000144,
    "name": "api_channel_01",
    "model": 0,
    "serialPort": "/devredfffffffff",
    "baudRate": 300,
    "dataBits": 5,
    "checkBits": 0,
    "stopBits": 1,
    "ip": "",
    "port": 0,
    "created": 1566439063,
    "modified": 0
  }
}

5.2.2修改Modbus通道

功能描述:修改指定通道。

PUT  /api/v1/gateway/channels/{id}

Path:

Name Type Description Required
id int 通道ID Yes

Body:

Name Type Description Required
name string 通道名称 No
serialPort string 串口号 No
baudRate string 波特率(300/600/1200/1440/2400/4800/9600/19200/38400 /43000/56000/57600/115200/230400)默认为1200 No
dataBits int 数据位(5/6/7/8)默认为8 No
checkBits int 数据位(无校验:0;奇校验:1;偶校验:2)默认为无校验 No
stopBits int 停止位(1/2)默认为2 No

Body example:

{
  "name": "modbuschannel"
}

cURL example:

curl --location --request PATCH '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/gateway/channels/110?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
              "name": "modbuschannel"
            }'

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": 1
}

5.2.3查询Modbus通道详情

功能描述:根据id查询指定通道,返回该通道的具体信息。

GET  /api/v1/gateway/channels/{id}

Path:

Name Type Description Required
id int 通道ID Yes

cURL example:

curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/gateway/channels/110?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}' \
--header 'platform: 3' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 当前页码
gatewayId int 网关ID
name string 通道名称
model int 通道模式(0 : RTU/ 1 : TCP)
ip string ip地址
port long 端口
serialPort string 串口号
baudRate long 波特率
dataBits int 数据位
checkBits int 是否校验数据位
stopBits int 停止位
created long 创建时间
modified long 更新时间

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 14,
    "gatewayid": 10000144,
    "name": "api_channel_01",
    "model": 0,
    "serialPort": "/devredfffffffff",
    "baudRate": 300,
    "dataBits": 5,
    "checkBits": 0,
    "stopBits": 1,
    "ip": "",
    "port": 0,
    "created": 1566439063,
    "modified": 0
  }
}

5.2.4查询边缘节点下的所有通道

功能描述:查询指定边缘节点下的所有通道,返回该通道信息列表。

GET  /api/v1/gateway/channels

Query:

Name Type Description Required
gatewayId int 网关设备ID Yes

cURL example:

curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/gateway/channels?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}&gatewayId=10000807' \
--header 'platform: 3' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
data struct[] Modbus通道列表

Response data data的子对象结构体:

Name Type Description
id int 当前页码
gatewayId int 网关ID
name string 通道名称
model int 通道模式(0 : RTU/ 1 : TCP)
ip string ip地址
port long 端口
serialPort string 串口号
baudRate long 波特率
dataBits int 数据位
checkBits int 是否校验数据位
stopBits int 停止位
created long 创建时间
modified long 更新时间

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": [
    {
      "id": 14,
      "gatewayid": 10000144,
      "name": "api_channel_01",
      "model": 0,
      "serialPort": "/dev",
      "baudRate": 300,
      "dataBits": 5,
      "checkBits": 0,
      "stopBits": 2,
      "ip": "",
      "port": 0,
      "created": 1566439063,
      "modified": 1566440081
    }
  ]
}

5.2.5删除Modbus通道

功能描述:删除指定通道。

DELETE  /api/v1/gateway/channels/{id}

Path:

Name Type Description Required
id int 通道ID Yes

cURL example:

curl --location --request DELETE '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/gateway/channels/110?accessKeyId={accessKeyId}&signatureNonce=529&signature={signature}' \
--header 'platform: 3' \
--header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

5.2.6根据设备ID查询Modbus通道列表

功能描述:查询指定设备下的所有通道,返回该通道信息列表。

GET  /api/v1/device/4/channel/device/{deviceId}

Path:

Name Type Description Required
deviceId int 设备ID Yes

cURL example:

curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/device/4/channel/device/10000807?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}' \
--header 'platform: 3' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
data struct[] Modbus通道列表

Response data data的子对象结构体:

Name Type Description
id int 通道ID
gatewayId int 网关ID
name string 通道名称
model int 通道模式(0 : RTU/ 1 : TCP)
ip string ip地址
port long 端口
serialPort string 串口号
baudRate long 波特率
dataBits int 数据位
checkBits int 是否校验数据位
stopBits int 停止位
created long 创建时间
modified long 更新时间

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": [
    {
      "id": 14,
      "gatewayid": 10000144,
      "name": "api_channel_01",
      "model": 0,
      "serialPort": "/dev",
      "baudRate": 300,
      "dataBits": 5,
      "checkBits": 0,
      "stopBits": 2,
      "ip": "",
      "port": 0,
      "created": 1566439063,
      "modified": 1566440081
    }
  ]
}

5.2.7创建Modbus设备的边缘节点通道配置

功能描述:为Modbus设备创建一个网关通道配置,根据此配置可以实现该设备数据的上传和下发。

注意:此接口多次调用会覆盖旧的Modbus设备网关通道配置。

POST  /api/v1/devices/modbus/channel-config/gateway

Body:

Name Type Description Required
id int Modbus设备ID Yes
channelId int 网关通道配置ID Yes
modbusAddress int 从站号 Yes
collectTime int 设备数据采集间隔 , 不小于10S Yes

Body example:

{
    "id": 101,
    "channelId": 100,
    "modbusAddress": 10,
    "collectTime": 11
}

cURL example:

curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/devices/modbus/channel-config/gateway?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                "id": 101,
                "channelId": 100,
                "modbusAddress": 10,
                "collectTime": 11
            }'

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": 1
}

5.2.8获取Modbus设备的边缘节点通道配置

功能描述:获取Modbus设备的网关通道配置。

GET  /api/v1/devices/modbus/channel-config

Query:

Name Type Description Required
id int Modbus设备ID Yes

cURL example:

curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/devices/modbus/channel-config?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}&id=10000807' \
--header 'platform: 3' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 设备ID
channelId int 通道ID
modbusAddress int 从站号
source int Modbus的父类类型
collectTime int 设备数据采集间隔

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 10000196,
    "channelId": 16,
    "modbusAddress": 1,
    "collectTime": 10
  }
}

results matching ""

    No results matching ""